package al.softsynergy.auk.ui;

import al.softsynergy.auk.data.ejbs.IAukBean;
import al.softsynergy.auk.ui.ankesa.AnkesaUI;

import com.vaadin.event.LayoutEvents.LayoutClickEvent;
import com.vaadin.event.LayoutEvents.LayoutClickListener;
import com.vaadin.ui.Component;
import com.vaadin.ui.CustomLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.Window;

public class MainWindow extends Window implements LayoutClickListener{

	/**
	 * 
	 */
	private static final long serialVersionUID = -4832433200896453960L;

	private MenuItem clientCare;
	private MenuItem technicalDepartment;
	private MenuItem economicDepartment;
	private MenuItem personel;
	
	private AnkesaUI ankesaUI;
	private IAukBean aukBean;
	
	private CustomLayout mainContent;
	
	
	public MainWindow(String caption, IAukBean aukBean){
		super(caption);
		this.aukBean = aukBean;
		this.aukBean.login("ADMIN");
		mainContent = new CustomLayout("index");
		mainContent.addStyleName("mainContent");
		this.setContent(mainContent);
		
		this.clientCare = new MenuItem("Kujdesi ndaj klientit", this);
		mainContent.addComponent(clientCare, "clientCareMenu");
		
		this.technicalDepartment  = new MenuItem("Departamenti Teknik", this);
		mainContent.addComponent(technicalDepartment, "technicalDepartmentMenu");
		
		this.economicDepartment  = new MenuItem("Departamenti Ekonomik", this);
		mainContent.addComponent(economicDepartment, "economicDepartmentMenu");
		
		this.personel = new MenuItem("Personeli", this);
		mainContent.addComponent(personel, "personelMenu");
		
	}

	public void loadContentTitle(String title){
		Label label = new Label(title);
		this.mainContent.addComponent(label,"title");
	}
	
	public void loadSubContentTitle(String subContentTitle){
		Label label = new Label(subContentTitle);
		this.mainContent.addComponent(label, "subContentTitle");
	}
	public void loadSideBar(Component component){
		this.mainContent.addComponent(component, "sideBar");
	}
	
	public void loadContent(Component component){
		this.mainContent.addComponent(component, "content");
	}
	
	
	
	public IAukBean getAukBean() {
		 return this.aukBean;
	}
	

	public void loadAnkesaUI(){
		if (ankesaUI == null)
			this.ankesaUI = new AnkesaUI(this);

	}
	

	@Override
	public void layoutClick(LayoutClickEvent event) {
		
		if (event.getSource() == this.clientCare) {
			getWindow().showNotification( "clientCare");
			this.loadAnkesaUI();
		}
		else if (event.getSource() == this.technicalDepartment)
			getWindow().showNotification( "technicalDepartment");
		else if (event.getSource() == this.economicDepartment)
			getWindow().showNotification( "economicDepartment");
		else if (event.getSource() == this.personel)
			getWindow().showNotification( "personel");
			
		
	}
	
}
